

$(document).ready(function() {
	if($("#content").length == 0){
		return;
	}
	
	var loginContainer = $("<div />", { style : "width: 943px; margin: 0 auto;"});
	$("#content").before(loginContainer);
	loginContainer.load("parts/main_menu.html #main-menu", function(){
		$("#main-menu #more").bind("click", function() {
			window.location = "menu.html";
		});
		
		
		
		$("#main-menu #event").bind("click", function() {
			if ($("#dial-event").length != 0) {
				return;
			}
			
			$("#content").module.create({ title : "Lista de eventos" }).live({
				name : "news",
				source : "parts/event.html",
				callback : function(data) {
					$(".event .content").html(data.content);
					$(".event .sender").html(data.sender.name);
					$(".content .title").html(data.title);
					$(".event .comment").button();
					$(".event .picture").attr("src", data.sender.picture);
				}
			}).open("dial-event");
		});
		
		
		
		
		/* ***** MENU DEPOIMENTOS ***** */
		$("#main-menu #testimony").bind("click", function() {
			if ($("#dial-testimony").length != 0) {
				return;
			}
			
			$("#content").module.create({ title : "Depoimentos" }).live({
				name : "testimony",
				source : "parts/testimony.html .testimony",
				callback : function(data) {
					$(".testimony .content").html(data.content);
					$(".testimony .sender").html(data.sender.name);
					$(".testimony .comment").button();
					$(".testimony .picture").attr("src", data.sender.picture);
				}
			}).open("dial-testimony");
		});
		/* ***** MENU DEPOIMENTOS ***** */
		
		/* ***** MENU NOTICIAS ***** */
		$("#main-menu #news").bind("click", function() {
			if ($("#dial-news").length != 0) {
				return;
			}
			
			$("#content").module.create({ title : "Últimas Notícias" }).live({
				name : "news",
				source : "parts/news.html .news",
				callback : function(data) {
					$(".news .content").html(data.content);
					$(".news .sender").html(data.sender.name);
					$(".content .title").html(data.title);
					$(".news .comment").button();
					$(".news .picture").attr("src", data.sender.picture);
				}
			}).open("dial-news");
		});
		/* ***** MENU NOTICIAS ***** */
	});
});